package com.zhoujing.cinema.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhoujing.cinema.dao.CinemaDao;
import com.zhoujing.cinema.entity.*;
import com.zhoujing.cinema.service.CinemaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：ywj
 * @date ：Created in 2020/3/22 17:59
 * @description：
 * @modified By：
 * @version: $
 */
@Service
public class CinemaServiceImpl implements CinemaService {
    @Autowired
    public CinemaDao cinemaDao;
    @Override
    public City findIdByName(String name) {
        return cinemaDao.selectIdByName(name);
    }

    @Override
    public List<City> findAllCity() {
        return cinemaDao.selectAllCity();
    }

    @Override
    public List<CinemaBrand> findCinemaBrand(Integer id) {
        return cinemaDao.selectCinemaBrand(id);
    }

    @Override
    public List<CinemaArea> findCinemaArea(Integer id) {
        return cinemaDao.selectCinemaArea(id);
    }

    @Override
    public List<CinemaType> findCinemaType(Integer id) {
        return cinemaDao.selectCinemaType(id);
    }

    @Override
    public PageInfo<Cinema> findCinema(Integer id,Integer pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Cinema> cinemas= cinemaDao.selectCinema(id);
        PageInfo<Cinema> pageInfo = new PageInfo<>(cinemas);
        return pageInfo;
    }

    @Override
    public PageInfo<Cinema> findCinemaWithQuery(CinemaDto cinemaDto, Integer pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Cinema> cinemas= cinemaDao.selectCinemaWithQuery(cinemaDto);
        PageInfo<Cinema> pageInfo = new PageInfo<>(cinemas);
        return pageInfo;
    }

    @Override
    public Cinema findCinemaById(Integer id) {
        return cinemaDao.selectCinemaById(id);
    }

    @Override
    public List<Session> findTodaySession(Session session) {
        return cinemaDao.selectTodaySession(session);
    }

    @Override
    public Session findSessionById(Integer id) {
        return cinemaDao.selectSessionById(id);
    }

    @Override
    public void updateSeat(Session session) {
        cinemaDao.updateSeat(session);
    }

    @Override
    public void addOrder(Order order) {
        cinemaDao.insertOrder(order);
    }

    @Override
    public List<Order1> findOrderByUserId(Integer userId) {
        return cinemaDao.selectOrderByUserId(userId);
    }

    @Override
    public PageInfo<Cinema> findCinemas(Integer pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Cinema> cinemas= cinemaDao.selectCinemas();
        PageInfo<Cinema> pageInfo = new PageInfo<>(cinemas);
        return pageInfo;
    }

    @Override
    public PageInfo<Cinema> searchCinemas(String name,Integer pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Cinema> cinemas= cinemaDao.searchCinemas(name);
        PageInfo<Cinema> pageInfo = new PageInfo<>(cinemas);
        return pageInfo;
    }

    @Override
    public void insertCinema(Cinema cinema) {
        cinemaDao.insertCinema(cinema);
    }

    @Override
    public void updateCinema(Cinema cinema) {
        cinemaDao.updateCinema(cinema);
    }

    @Override
    public void updateCinema1(Cinema cinema) {
        cinemaDao.updateCinema1(cinema);
    }

    @Override
    public Cinema selectCinemaById1(Integer id) {
        return cinemaDao.selectCinemaById1(id);
    }

    @Override
    public void insertSession(Session session) {
        cinemaDao.insertSession(session);
    }

    @Override
    public void updateSession(Session session) {
        cinemaDao.updateSession(session);
    }

    @Override
    public Session selectSessionByIds(Integer id) {
        return cinemaDao.selectSessionByIds(id);
    }
}
